import tkinter

from SubThread.MainThread import MainThread


class WindowSizeChageEvenet(MainThread):
    """
    DESCRIPT:
        MainThread的子类 修改了Validate
        init需要传入一个Window类 TypeHint为MainWindows
    SCRIPT:
        当MainWindows对象的Size发送改变的时候触发线程事件的
    """

    def __init__(self, mw):
        super().__init__()
        self.mw = mw
        self.historySize = (0, 0)

    def Validate(self):

        win: tkinter.Tk = self.mw.win
        TmpSize = (win.winfo_width(), win.winfo_height())
        if TmpSize != self.historySize:
            self.historySize = TmpSize
            return True
        return False
